//
//  JHHotUserMoveTableViewCell.m
//  Liberty Voice
//
//  Created by dlios on 15-5-18.
//  Copyright (c) 2015年 ClearLove. All rights reserved.
//

#import "JHHotUserMoveTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface JHHotUserMoveTableViewCell ()

@property(nonatomic,retain)UIImageView *image;
@property(nonatomic,retain)UILabel *title;
@property(nonatomic,retain)UILabel *label;
@property(nonatomic,retain)UIImageView *playImage;
@property(nonatomic,retain)UILabel *play;
@property(nonatomic,retain)UIImageView *perImage;
@property(nonatomic,retain)UILabel *per;

@end

@implementation JHHotUserMoveTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:_image];
        
        self.title = [[UILabel alloc] init];
//        _title.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_title];
        
        self.label = [[UILabel alloc] init];
//        _label.backgroundColor = [UIColor yellowColor];
        _label.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_label];
        
        self.playImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-xiangyou"]];
        [self.contentView addSubview:_playImage];
        
        self.play = [[UILabel alloc] init];
//        _play.backgroundColor = [UIColor yellowColor];
        _play.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_play];
        
        self.perImage =[[ UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-my"]];
        [self.contentView addSubview:_perImage];
        
        self.per = [[UILabel alloc] init];
//        _per.backgroundColor = [UIColor yellowColor];
        _per.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_per];
    }return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _image.frame = CGRectMake(20, 5, self.contentView.frame.size.width / 3, self.contentView.frame.size.height-10);
    
    _title.frame = CGRectMake(_image.frame.size.width + 30, 10, self.contentView.frame.size.width - _image.frame.size.width - 20, 30);
    
    _label.frame = CGRectMake(_title.frame.origin.x , 45, self.contentView.frame.size.width - _image.frame.size.width - 20, 25);
    
    _playImage.frame = CGRectMake(_image.frame.size.width + 30, self.contentView.frame.size.height - 30,  20, 20);
    _play.frame = CGRectMake(_playImage.frame.origin.x + 30, self.contentView.frame.size.height - 30,  50, 20);
    
    _perImage.frame = CGRectMake(_play.frame.origin.x + 60, self.contentView.frame.size.height - 30,  20, 20);
    _per.frame = CGRectMake(_perImage.frame.origin.x + 30, self.contentView.frame.size.height - 30,  50, 20);
    
}
- (void)setMove:(JHMoveMOdel *)move
{
    if (move != _move) {
        [_move release];
        _move = [move retain];
    }
    [_image sd_setImageWithURL:[NSURL URLWithString:move.largeLogo]];
    _title.text = move.nickname;
    _label.text = move.personDescribe;
    NSString *track = [NSString stringWithFormat:@"%ld",move.tracksCounts];
    _play.text = track;
    NSString *follow = @"";
    if (move.followersCounts < 10000) {
        follow = [NSString stringWithFormat:@"%ld", move.followersCounts];
    }else
        if (move.followersCounts > 10000) {
            follow = [NSString stringWithFormat:@"%.1f万", move.followersCounts / 10000.0];
        }
    _per.text = follow;
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
